<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
 #div1{
 width:150px;
 height:150px;
 /* background-color: green; */
}
 
</style>
</head>
<body>
	<div id="div1"
		style="width: 150px; height: 150px; background-color: red; position: relative;">
	哈哈哈</div>
	<script type="text/javascript">
		var div1 = document.getElementById('div1');
		document.onmousemove = function() {
			div1.style.left = (event.clientX - parseInt(div1.style.width) / 2)
					+ 'px'; 
			div1.style.top = (event.clientY - parseInt(div1.style.height) / 2)
					+ 'px';
		}
	</script>
</body>
</html>